<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>角色列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">角色名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="name" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit
                                    lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>

        <script type="text/html" id="myToolbarElem">
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-sm data-add-btn" lay-event="add">新增角色</button>
            </div>
        </script>

        <table class="layui-hide" id="myTableElem" lay-filter="myTableFilter"></table>
        <script type="text/html" id="myTableBarElem">
            <a class="layui-btn layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
            <a class="layui-btn layui-btn-xs data-count-edit" lay-event="delete">删除</a>
        </script>
    </div>
</div>
<script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../../js/layutil.js" charset="utf-8"></script>
<script src="../../js/col-utils.js" charset="utf-8"></script>
<script>
    var selected = [];
    var checkList = [];//全部
    var checked = [];//编辑
    layui.use(['form', 'table', 'slider'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;
        layutil.table('/myerp/role/list', colsutil.role_cols);

        /**
         * toolbar监听事件
         */
        table.on('toolbar(myTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'add') {  // 监听添加操作
                layutil.iframe('新增角色','/page/sys_role/role-add.html',null, null, function () {
                    table.reload('myTableElem');
                });
            }
        });

        table.on('tool(myTableFilter)', function (obj) {
            var data =obj.data;
            if (obj.event === 'delete') {  // 监听添加操作
                var str = "确定删除角色？";
                layutil.confirm(str, function () {
                    layutil.postForm("/myerp/role/delete", {id : data['id']});
                });
            } else if(obj.event === 'edit') {
                layutil.iframe('编辑角色','/page/sys_role/role-edit.html',data);
            }

        });
    });
</script>
<script>

</script>

</body>
</html>